package com.wbl.tijiancms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wbl.tijiancms.pojo.Hospital;
import com.wbl.tijiancms.response.ApiRestResponse;
import com.wbl.tijiancms.response.TijianExceptionEnum;
import com.wbl.tijiancms.service.HospitalService;
import com.wbl.tijiancms.mapper.HospitalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author yy
* @description 针对表【hospital】的数据库操作Service实现
* @createDate 2024-09-18 10:09:07
*/
@Service
public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital>
    implements HospitalService{

    @Autowired
    HospitalMapper hospitalMapper;

    @Override
    public ApiRestResponse getHospitalInfo(Hospital hospital) {
        QueryWrapper<Hospital> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hpId",hospital.getHpid());
        Hospital hp = hospitalMapper.selectOne(queryWrapper);
        if (hospital==null){
            return ApiRestResponse.error(TijianExceptionEnum.NO_HOSPIATL);
        }else {
            return ApiRestResponse.success(hp);
        }
    }

    @Override
    public ApiRestResponse getHospitalList() {
        List<Hospital> hospitals= hospitalMapper.selectList(null);
        return ApiRestResponse.success(hospitals);
    }
}




